package cn.jsu.oj.judgment.thread;


import cn.jsu.oj.judgment.factory.ApplyRoleFactory;
import cn.jsu.oj.judgment.pojo.AbstractPack;
import lombok.extern.slf4j.Slf4j;
import static cn.jsu.oj.judgment.config.DataStructureConfig.messageQueue;

@Slf4j
public class ApplyTaskThread implements Runnable{

    public static int taskCount;

    
    @Override
    public void run() {
        while (true) {
            try {
                AbstractPack abstractPack = messageQueue.take();
                //工厂模式
                /* 12.判题任务    89. 唤醒申请   21，任务数量应答*/
                ApplyRoleFactory.map.get(abstractPack.getTypeNo()).handle(abstractPack,taskCount);
            } catch (Exception e) {
                log.error(e.getLocalizedMessage(),e);
            }
        }
    }
}
